<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String contextPath = request.getContextPath();
	if(session.getAttribute("logined") != null){
		response.sendRedirect(contextPath + "/home.jsp");
	}	
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
	content="width=device-width,initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>准备好跟我携手一起了么？</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
<script type="text/javascript" src="js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="js/jquery.form-2.82.js"></script>
<script type="text/javascript">
	$(function(){
		$("#login_form").ajaxForm({
			beforeSubmit:function(){
				var u = $("input[name='username']");
				var username = u.val();
				if(username.length==0 || username == "用户名"){
					alert("还是填个用户名吧！");
					u.focus();
					return false;
				}
				var p = $("input[name='pwd']");
				var pwd = p.val();
				if(pwd.length==0 || pwd == "输入您的密码"){
					alert("密码是不能少的哦...");
					p.focus();
					return false;
				}
				var e = $("input[name='email']");
				var email = e.val();
				if(email.length==0 || email == "点这里输入“电子邮箱”"){
					alert("别懒了，填个邮箱方便很多的...");
					e.focus();
					return false;
				}else{
					var regex =  /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
					if(!email.match(regex)){
						alert("真粗心，邮箱填错了啦...");
						e.focus();
						return false;
					}
				}				
			},
			success:function(data){
				if(data){
				data = eval("("+data+")");
				if(data.error){
					alert(data.error);
					return;
				}
				location.href="home.jsp";
				}
			}
		});;
	});
</script>
</head>
<body>
	<header>
		<div class="logo">
			<a href="<%=contextPath%>/index.jsp"><img src="img/kitty64.png" width="60" /></a>
		</div>
		<div class="title">找密码</div>
		<div class="rightMenu">
			<ul>
				<li><a href="index.jsp">登录</a></li>
			</ul>
		</div>
	</header>
	<section>
		<article>
			<div class="title">认真填下面的邮箱地址哦，密码将发到这里...</div>
			<form id="login_form" action="<%=contextPath%>/action?action=user&method=resetpwd" method="post">
				<div class="formLine">
					<input type="text" class="textinput" value="点这里输入“电子邮箱”" name="email"  onblur="(this.value=='')?this.value='点这里输入“电子邮箱”':this.value" onfocus="if(this.value=='点这里输入“电子邮箱”'){this.value='';};this.select();"/>
				</div>
				<div class="formLine">
					<div class="btnSet">
						<button type="submit" class="blueBtn">找回密码</button>
					</div>
				</div>
			</form>
		</article>
	</section>
</body>
</html>